#/bin/sh!
SCRIPT_PATH=/net/192.168.200.254/scratch/scripts/openstack/


mkdir ~/conf.save

packages="mysql mysql-server MySQL-python openstack-keystone python-keystoneclient openstack-glance python-glanceclient openstack-nova-api openstack-nova-cert openstack-nova-conductor openstack-nova-c
onsole openstack-nova-novncproxy openstack-nova-scheduler python-novaclient openstack-neutron openstack-neutron-ml2 python-neutronclient memcached python-memcached mod_wsgi openstack-dashboard openstack-cin
der  qpid-cpp-server "

service_nova="openstack-nova-api
openstack-nova-cert
openstack-nova-consoleauth
openstack-nova-scheduler
openstack-nova-conductor
openstack-nova-novncproxy
"
service_cinder="openstack-cinder-api
openstack-cinder-scheduler
openstack-cinder-volume
"
service_neutron="openstack-nova-api
openstack-nova-scheduler
openstack-nova-conductor
neutron-server
"
service_glance="openstack-glance-api
openstack-glance-registry
"

services01="mysqld qpidd"
service02="$service_nova $service_neutron $service_glance $service_cinder "
service03="httpd memcached"

for serv in $service02 $service03 $services01; do
        service $serv stop;
done;




if [ ! -d ~/conf.save ]; then
	rm -f ~/conf.save;
	mkdir ~/conf.save;
fi


for fname in `ls $SCRIPT_PATH/conffiles/ |grep _etc`; do
        conffile=`echo $fname | sed s#_#/#g`;
        if [ "$fname" == "_etc_neutron_plugins_ml2_ml2_conf.ini" ]; then
                conffile="/etc/neutron/plugins/ml2/ml2_conf.ini";
        fi
	mv $conffile ~/conf.save/$conffile.`date +%s`
done

#rm -rf /var/log/nova
#rm -rf /var/log/neutron



mv /etc/openstack-dashboard/local_settings ~/~/conf.save/local_settings.`date +%s`
 

mv /var/lib/mysql /var/lib/mysql.save.`date +%s`

yum -y remove $packages

